package com.qfjy.controller;

import com.qfjy.common.util.result.ResultCode;
import com.qfjy.common.util.result.ResultJson;
import com.qfjy.entity.po.Demo;
import com.qfjy.service.DemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("demo")
@Slf4j
@Api(value = "案例模块")
public class DemoController {

    @Autowired
    private DemoService demoService;
    /* TODO 集成Redis**/
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @GetMapping("info")
    @ResponseBody
    @ApiOperation(value = "查询案例列表数据")
    public Object info() {
        log.info("移动端-微信微服务--》请求");
        List<Demo> list = demoService.selectList();

        redisTemplate.opsForValue().set("java2302", "java2302");

        return new ResultJson<>(list, ResultCode.SUCCESS);
    }
}
